<template>
	<view>
    <Navbar title="工作台" bgColor="#fff" :hideBtn="true" :h5Show="false"></Navbar>
    <H5Navbar title="工作台"></H5Navbar>
<!--    <Gap />-->
    <view style="padding: 40rpx; background-color: #fff; margin-top: 40rpx; min-height: 600rpx;">
      <u-tabs
        :activeStyle="{
          color: '#303133',
          fontSize: '40rpx',
          fontWeight: 'bold',
          transform: 'scale(1.05)'
        }"
        :inactiveStyle="{
          color: '#606266',
          fontSize: '36rpx',
          transform: 'scale(1)'
        }"
        :list="tabs"
        @change="tabChange">
      </u-tabs>
      <view v-if="activeKey == 'work'" style="padding: 40rpx 0;">

        <u-grid col="3" style="margin-top: 40rpx;" v-if="showCreate || showAll">
          <u-grid-item @click="navigateTo('/pages/work/customer/MyCreateCust')" v-if="showCreate">
            <text class="iconfont icon-supervision" style="color: #2979ff;font-size: 60rpx"></text>
            <text class="btn-text">我创建的客户</text>
          </u-grid-item>
          <u-grid-item @click="navigateTo('/pages/work/customer/AllCust')" v-if="showAll">
            <text class="iconfont icon-supervision" style="color: #2979ff;font-size: 60rpx"></text>
            <text class="btn-text">全部客户</text>
          </u-grid-item>
        </u-grid>
      </view>
<!--      <view v-if="activeKey == 'plugin'" style="padding: 40rpx 0;">-->
<!--        <u-grid col="3" style="margin-top: 40rpx;">-->
<!--          <u-grid-item>-->
<!--            <text class="iconfont icon-ribaoS" style="color: #2979ff;font-size: 60rpx"></text>-->
<!--            <text class="btn-text">我的日报</text>-->
<!--          </u-grid-item>-->
<!--          <u-grid-item>-->
<!--            <text class="iconfont icon-ribaoS" style="color: #2979ff;font-size: 60rpx"></text>-->
<!--            <text class="btn-text">所有日报</text>-->
<!--          </u-grid-item>-->
<!--        </u-grid>-->
<!--      </view>-->

<!--      <view v-if="activeKey == 'systeam'"  style="padding: 40rpx 0;">-->
<!--        <u-grid col="3">-->
<!--          <u-grid-item @click="navigateTo('/pages/work/notice/manage')">-->
<!--            <u-icon name="edit-pen" color="#2979ff" size="60rpx"></u-icon>-->
<!--            <text class="btn-text">公告管理</text>-->
<!--          </u-grid-item>-->
<!--          <u-grid-item @click="navigateTo('/pages/work/user/list')">-->
<!--            <u-icon name="plus-people-fill" color="#2979ff" size="60rpx"></u-icon>-->
<!--            <text class="btn-text">用户管理</text>-->
<!--          </u-grid-item>-->
<!--          <u-grid-item>-->
<!--            <u-icon name="tags" color="#2979ff" size="60rpx"></u-icon>-->
<!--            <text class="btn-text">部门管理</text>-->
<!--          </u-grid-item>-->
<!--        </u-grid>-->
<!--        <u-grid col="3" style="margin-top: 40rpx;">-->
<!--          <u-grid-item>-->
<!--            <u-icon name="bookmark" color="#2979ff" size="60rpx"></u-icon>-->
<!--            <text class="btn-text">岗位管理</text>-->
<!--          </u-grid-item>-->
<!--        </u-grid>-->
<!--      </view>-->
    </view>
	</view>
</template>

<script>
import H5Navbar from "@/components/H5Navbar/index";
import Navbar from '@/components/navbar/Navbar'
import Gap from '@/components/gap/Gap'
import {getRouters} from "../../api/user";

export default {
  components: {
    Gap,
    Navbar,
    H5Navbar
  },
  data () {
    return {
      activeKey: 'work',
    //     ,{
    //   name: '系统管理',
    //   key: 'systeam'
    // }
    // {
    //   name: '工作汇报',
    //       key: 'plugin'
    // }
      tabs: [{
        name: '客户关系管理',
        key: 'work'
      }, ],
      todo: {
        notice: 2,
        task: 5,
        error: 1
      },
      showAll:false,
      showCreate:false
    }
  },
  onLoad(){
    getRouters().then(res =>{
      const ind = res.data.findIndex(item => item.name == 'CustomerManage')
      if(ind != -1){
        const index = res.data[ind].children.findIndex(item => item.name == 'AllCust')
        if(index != -1){
          this.showAll = true
        }
        else{
          this.showAll = false
        }

        const index1 = res.data[ind].children.findIndex(item => item.name == 'MyCreateCust')
        if(index != -1){
          this.showCreate = true
        }
        else{
          this.showCreate = false
        }
      }
    }).catch(()=>{
      this.showCreate = true
    })
  },
  methods: {
    tabChange (item) {
      this.activeKey = item.key;
    },
    navigateTo (url) {
      uni.navigateTo({ url: url })
    }
  }
}
</script>

<style lang="scss">

</style>
